$('document').ready(function(){
	
	
	
	/**
	* load ajax coin rank sms
	*
	**/
	$("#distributor").change(function(){
		
		var distributor = $("#distributor").val();

		var oParam = new Object();
		oParam.distributor = distributor;
			
		$.post(url_base + 'statistics/receipts/sms_number',oParam,function(data){
			
			var sms = '';
			var number = '';
			if(data.sms){				
				$.each(data.sms , function(i,item){
					sms += '<option value="' + item.sms_code + '">' + item.sms_code + '</option>';
				});				
			}
			$("#sms option:gt(0)").remove();
			$("#sms").append(sms);
			
			if(data.number){				
				$.each(data.number , function(i,item){
					number += '<option value="' + item.number_code + '">' + item.number_code + '</option>';
				});				
			}
			$("#number option:gt(0)").remove();
			$("#number").append(number);
			
		},'json');
		
	});

	
	$("#sms").change(function(){

		var distributor = $("#distributor").val();
		var sms = $("#sms").val();

			var oParam = new Object();
			oParam.distributor = distributor;
			oParam.sms = sms;
				
			$.post(url_base + 'statistics/receipts/get_number',oParam,function(data){
					
					var sms='';
					
					if(data){
						
						$.each(data , function(i,item){
							sms += '<option value="' + item.number_code + '">' + item.number_code + '</option>';
						});			
					}
					$("#number option:gt(0)").remove();
					$("#number").append(sms);
				
			},'json');

	});	
	/**
	* ajax lay dich vu trong thong ke nha cung cap noi dung
	*/
	$("#content").change(function(){

		var content = $("#content").val();
			var oParam = new Object();
			oParam.content = content;
				
			$.post(url_base + 'statistics/receipts/getservice',oParam,function(data){
					
					var sms='';
					
					if(data){
						
						$.each(data , function(i,item){
							sms += '<option value="' + item.id + '">' + item.sv_name + '</option>';
						});			
					}
					$("#service option:gt(0)").remove();
					$("#service").append(sms);
				
			},'json');

	});	
	
	
	$("#selectmonth").click(function(){
				$("#fromto").hide();	
				$("#pmonth").hide();
				$("#month").hide();
				$("#nomal").show();
				$("#pyear").show();
				$("#year").show();
	});	
	
	$("#selectday").click(function(){
				$("#nomal").show();
				$("#fromto").hide();
				$("#pmonth").show();
				$("#month").show();
				$("#pyear").show();
				$("#year").show();
				$("#day").hide();
				$("#pday").hide();
	});	
	
	$("#selectyear").click(function(){
		$("#nomal").show();
				$("#fromto").hide();
				$("#pmonth").hide();
				$("#month").hide();
				$("#pyear").hide();
				$("#year").hide();
	});	

	$("#timeto").click(function(){
					
		$("#nomal").hide();
		$("#fromto").show();
	
	});	
	$("#selecthour").click(function(){					
		$("#pday").show();
		$("#day").show();
		$("#nomal").show();
		$("#fromto").hide();
		$("#pmonth").show();
		$("#month").show();
		$("#pyear").show();
		$("#year").show();
	});	
	
});
function searchmo()
{
	var sms = $("#sms").val();
	var dis = $("#distributor").val();
	var number = $("#number").val();
	var adv_start = $("#adv_start").val();
	var key = $("#key").val();
	if(adv_start == '') adv_start = -1;
	if(key == '') key = -1;
	if(sms == '') sms = -1;
	window.location.href = url_base + 'statistics/report/reportmodetail/'+dis+'/'+number+'/'+sms+'/'+key+'/'+adv_start;
	return false;
}

function searchmt()
{
	var dis = $("#distributor").val();
	var sms = $("#sms").val();
	var number = $("#number").val();
	var adv_start = $("#adv_start").val();
	var key = $("#key").val();
	if(adv_start == '') adv_start = -1;
	if(key == '') key = -1;
	if(sms == '') sms = -1;
	window.location.href = url_base + 'statistics/report/reportmtdetail/'+dis+'/'+number+'/'+sms+'/'+key+'/'+adv_start;
	return false;
}